package com.example.bbs.kafka.producer;

import com.alibaba.fastjson.JSON;
import com.example.bbs.domain.entity.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;


/**
 * 生产通知信息
 */
@Component
public class NoticeProducer {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void sendCommentNotice(String topic, Comment comment) {
        kafkaTemplate.send(topic, JSON.toJSONString(comment));
    }



}
